package com.runvp.netty.server.handler;


import com.runvp.common.model.tcp.MessageReceiveBody;
import com.runvp.common.model.tcp.MessageResBody;
import com.runvp.common.threads.ThreadPoolActuator;
import com.runvp.netty.runnables.DeviceResFeeSchemeRunnable;
import com.runvp.service.tcp.TcpService;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;


/**
 * 设备应答收费方案 -设备自主发起
 */
@Slf4j
public class DeviceResFeeSchemeHandle extends BizHandle{


    private MessageReceiveBody parseBody;

    private TcpService tcpService;

    public DeviceResFeeSchemeHandle(TcpService tcpService, MessageReceiveBody parseBody){
        this.parseBody = parseBody;
        this.tcpService = tcpService;
    }
    /**
     * 设备应答收费方案
     */
    public MessageResBody handle(Channel channel){
        long st = System.currentTimeMillis();
        try{
            //线程执行
            DeviceResFeeSchemeRunnable runnable = new DeviceResFeeSchemeRunnable(channel,tcpService,parseBody);
            ThreadPoolActuator.exeTask(runnable);
            return null;
        }finally {
            log.info("本次设备应答收费方案响应时间:【{} ms】",(System.currentTimeMillis()-st));
        }
    }


}
